Repository navigation
feat(events): keep the event stream across restarts, and berth why ID - #330
Merged
Merged
Conversation
berthd appends each event to events.jsonl in the state directory and reads the last 1000 back at start, so sequence numbers and lease numbers go on after a restart and each start is a node.started event. berth why ID|ENGINE prints one lease's events as a story: the waits, the grant, each drain and who it was for, the release, and the restarts it lived through.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users
berth why IDanswers "why did my engine wait, get drained or get refused" in one command. It prints everyevent berthd kept about the lease, oldest first, in plain words.
berth why ENGINEreads that engine's newestlease. A lease that still holds or waits ends with where it stands now. A lease a restart cut off names the
lease its engine re-attached as.
events.jsonlin the state directory(
--events,""keeps the old memory-only ring), reads the last 1000 back at start, and goes on numberingafter them. Lease numbers go on too, so a lease ID names one lease across deploys (before, every restart
started again at
-1). Each start is anode.startedevent that names the version.This is the "persisted decision log and
berth why" step of the Berth Next plan. The broker's existing reasonsare the decisions; this keeps them and reads them back per lease.
Proof
internal/eventlog: a restart keeps the events, Last and LastLease; a torn last line is skipped and the nextevent starts its own line; the file rotates at its cap and the rotated events still load; a missing state
directory is created.
internal/cli:whyOfover a literal replay of the 2026-11-12 strata drain, including a restart and are-attach;
berth whyagainst a real socket (holder story with the drain reason, a waiter's JSON withnow.state = waiting, an unknown name refused).lease.
berth eventsshowed seq 1-10 with twonode.startedlines, and the second lease wasdemo-2, not asecond
demo-1. That run found the missing-directory bug, which now has its own test.proof.shfull: build, gofmt, vet, tests, Windows build and vet, golangci-lint.